<?php
try {

    $zip = new ZipArchive();

    $filename = "db/zip/test.zip";

    if ($zip->open($filename, ZIPARCHIVE::CREATE) == TRUE) {
        //exit("cannot open <$filename>\n");
    }

    //$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n");
    //$zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n");
    $zip->addFile("uploadFileSample.php", "uploadFileSample.php");
    $zip->addFile("src/check.php", "check.php");
    //echo "numfiles: " . $zip->numFiles . "\n";
    //echo "status:" . $zip->status . "\n";
    $zip->close();


    header("Content-Description: File Transfer");
    header("Content-Type: application/force-download");
    header("Content-Type: application/zip");
    header("Content-Disposition: attachment; filename=\"FileName.zip\"");
    readfile($filename);
} catch (Exception $e) {
    echo "asd";
    echo $e->getTrace();
}
?>